﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="DetailsEntrySection.xaml.cs" company="Mar3ek">
//   This code is licensed under the Mozilla Public License 2.0.
//   You can find the full license text at the following address:
//   https://winkee.codeplex.com/license
// </copyright>
// <summary>
//   Defines the DetailsEntrySection type.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace WinKee.Controls
{
    using Windows.System;
    using Windows.UI.Xaml;

    using WinKee.Models;

    /// <summary>
    /// The control for displaying additional entry details.
    /// </summary>
    public sealed partial class DetailsEntrySection
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="DetailsEntrySection"/> class.
        /// </summary>
        public DetailsEntrySection()
        {
            this.InitializeComponent();
        }

        /// <summary>
        /// Gets the entry.
        /// </summary>
        private PasswordEntry Entry
        {
            get
            {
                return (PasswordEntry)this.DataContext;
            }
        }

        /// <summary>
        /// Attempts to navigate to the entry URL.
        /// </summary>
        /// <param name="sender">
        /// The event sender.
        /// </param>
        /// <param name="e">
        /// The event arguments.
        /// </param>
        private void NavigateToUrlButton_OnClick(object sender, RoutedEventArgs e)
        {
            if (this.Entry.Url == null)
            {
                return;
            }

            Launcher.LaunchUriAsync(this.Entry.Url);
        }
    }
}
